When executing managed code in a virtual machine (VM) environment, an application can run on different platforms. In such VM environments, native resources are typically allocated to applications using system calls. These system calls can be made when executing code in the VM environment by callers from class libraries. These class libraries commonly call through to the native operating system to perform low level functionality, such as drawing and windowing management. When these system calls are made, native resources are allocated as an effect of the library call from the caller. These native resources must be kept in synchronization with their counterpart in a managed code portion of the VM. When the managed code portion of the VM is through using the native resources, it is desirable that these native resources be freed so that they can be allocated for use by other applications.
Current techniques for exposing class libraries in a VM environment require a substantial amount of overhead when marshalling the data necessary to create, maintain synchronization, and destroy native resources that are involved in applications, and components thereof (e.g. such as User Interface (UI) resources involved in drawing and windowing management). In many computer-based applications, a new native resource is produced each time a new native resource object is created. A developer who writes or codes an application can inadvertently neglect the effects on the processor speed and memory consumption that occurs when the code fails to release a large number of native resources that have been allocated to the application. Such neglect can slow down processor speed, and make memory and native resources unavailable to other applications and components thereof.
A routine can be written by a developer to remove native resource objects that have been produced by an application. Such a routine to remove native resources must be conscientiously coded due to the significant processing required for its execution and due to the need to remove each of the native resources individually. Alternately, the native resources can be removed after some prescribed period, in which case there may be a considerable number of native resources waiting for removal for the duration of the prescribed period. Storing such a considerable number of native resources may make such tasks as drawing and windowing management slow in applications that require corresponding native resources (e.g. UI resources). Additionally, present computer applications typically produce multiple concurrently-saved copies of the native resource. For example, as a UI resource is transferred between the VM, the native environment, and the operating system (OS) itself, a copy of each UI resource object is stored in memory associated with each location.
Applications that run on such computer environments as stand alone computers, networked computer environments, and computer devices typically inefficiently manage native resources, but such inefficiency is typically ignored due to the large processing abilities of these computer environments. Smaller and less powerful, memory constrained and processor constrained devices (i.e. resource constrained devices) such as personal digital assistants (PDAs), cellular telephones, computer devices, embedded devices, microprocessor devices, and microcomputer devices are becoming increasingly popular. Resource constrained devices rely on more limited software, processors, memory and operating systems than those applied to full size computer environments. Applying a large number of system calls to resource constrained devices commonly make the devices prohibitively slow to perform many application functions. The system calls for native resources in resource constrained devices (especially for demanding applications that require extensive use of UI resources) are so processor intensive that the processor and memory resources become significantly strained. A large number of such system calls results in undesirable performance characteristics. It would be an advantage in the art to free a native resource after its use by an application so that it can be made available for allocation to another application, where requirements for the same that are placed upon the developer of the application are minimal. Consequently, there is a need for improved methods, apparatuses, and computer readable medium that can provide such a capability.